﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using BoolanSlide.RedoUndo;
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;

namespace BoolanElement
{
    public class BooRectangleDialogElement:BooTextShapesBaseElement
    {
        Point figureStartPoint;
        public Point FigureStartPoint
        {
            get { return figureStartPoint; }
            set { figureStartPoint = value; }
        }

        Point roundedLeftTopPoint1;
        public Point RoundedLeftTopPoint1
        {
            get { return roundedLeftTopPoint1; }
            set { roundedLeftTopPoint1 = value; }
        }

        Point roundedLeftTopPoint2;
        public Point RoundedLeftTopPoint2
        {
            get { return roundedLeftTopPoint2; }
            set { roundedLeftTopPoint2 = value; }
        }

        Point roundedLeftTopPoint3;
        public Point RoundedLeftTopPoint3
        {
            get { return roundedLeftTopPoint3; }
            set { roundedLeftTopPoint3 = value; }
        }

        Point lineTopStartPoint;
        public Point LineTopStartPoint
        {
            get { return lineTopStartPoint; }
            set { lineTopStartPoint = value; }
        }

        Point lineTopEndPoint;
        public Point LineTopEndPoint
        {
            get { return lineTopEndPoint; }
            set { lineTopEndPoint = value; }
        }

        Point roundedRightTopPoint1;
        public Point RoundedRightTopPoint1
        {
            get { return roundedRightTopPoint1; }
            set { roundedRightTopPoint1 = value; }
        }

        Point roundedRightTopPoint2;
        public Point RoundedRightTopPoint2
        {
            get { return roundedRightTopPoint2; }
            set { roundedRightTopPoint2 = value; }
        }

        Point roundedRightTopPoint3;
        public Point RoundedRightTopPoint3
        {
            get { return roundedRightTopPoint3; }
            set { roundedRightTopPoint3 = value; }
        }

        Point lineRightStartPoint;
        public Point LineRightStartPoint
        {
            get { return lineRightStartPoint; }
            set { lineRightStartPoint = value; }
        }

        Point lineRightEndPoint;
        public Point LineRightEndPoint
        {
            get { return lineRightEndPoint; }
            set { lineRightEndPoint = value; }
        }

        Point roundedRightBottomPoint1;
        public Point RoundedRightBottomPoint1
        {
            get { return roundedRightBottomPoint1; }
            set { roundedRightBottomPoint1 = value; }
        }

        Point roundedRightBottomPoint2;
        public Point RoundedRightBottomPoint2
        {
            get { return roundedRightBottomPoint2; }
            set { roundedRightBottomPoint2 = value; }
        }

        Point roundedRightBottomPoint3;
        public Point RoundedRightBottomPoint3
        {
            get { return roundedRightBottomPoint3; }
            set { roundedRightBottomPoint3 = value; }
        }

        Point lineDialog1StartPoint;
        public Point LineDialog1StartPoint
        {
            get { return lineDialog1StartPoint; }
            set { lineDialog1StartPoint = value; }
        }

        Point lineDialog1EndPoint;
        public Point LineDialog1EndPoint
        {
            get { return lineDialog1EndPoint; }
            set { lineDialog1EndPoint = value; }
        }

        Point lineDialog2StartPoint;
        public Point LineDialog2StartPoint
        {
            get { return lineDialog2StartPoint; }
            set { lineDialog2StartPoint = value; }
        }

        Point lineDialog2EndPoint;
        public Point LineDialog2EndPoint
        {
            get { return lineDialog2EndPoint; }
            set { lineDialog2EndPoint = value; }
        }

        Point lineBottomStartPoint;
        public Point LineBottomStartPoint
        {
            get { return lineBottomStartPoint; }
            set { lineBottomStartPoint = value; }
        }

        Point lineBottomEndPoint;
        public Point LineBottomEndPoint
        {
            get { return lineBottomEndPoint; }
            set { lineBottomEndPoint = value; }
        }

        Point roundedLeftBottomPoint1;
        public Point RoundedLeftBottomPoint1
        {
            get { return roundedLeftBottomPoint1; }
            set { roundedLeftBottomPoint1 = value; }
        }

        Point roundedLeftBottomPoint2;
        public Point RoundedLeftBottomPoint2
        {
            get { return roundedLeftBottomPoint2; }
            set { roundedLeftBottomPoint2 = value; }
        }

        Point roundedLeftBottomPoint3;
        public Point RoundedLeftBottomPoint3
        {
            get { return roundedLeftBottomPoint3; }
            set { roundedLeftBottomPoint3 = value; }
        }

        Point lineLeftStartPoint;
        public Point LineLeftStartPoint
        {
            get { return lineLeftStartPoint; }
            set { lineLeftStartPoint = value; }
        }

        Point lineLeftEndPoint;
        public Point LineLeftEndPoint
        {
            get { return lineLeftEndPoint; }
            set { lineLeftEndPoint = value; }
        }

        public override async Task<BooUIBase> Render(SaveOriginalElement saveOriginal, SaveForRedoUndo saveForRedoUndo)
        {
            BooRectangleDialog rect = new BooRectangleDialog(this, saveForRedoUndo);
            RedoUndoHelper.SaveOriginalStatus(rect);
            return rect;
        }
        public override async Task<BooUIBase> RenderForThumbNails()
        {
            BooRectangleDialog rect = new BooRectangleDialog(this);

            return rect;
        }

        public static BooRectangleDialogElement InitElementStyle()
        {
            BooRectangleDialogElement rectangleDialogElement = new BooRectangleDialogElement();
            rectangleDialogElement.ElementTransform.Rotate.Angle = 0;
            rectangleDialogElement.ElementTransform.Rotate.CenterX = 0;
            rectangleDialogElement.ElementTransform.Rotate.CenterY = 0;

            rectangleDialogElement.ElementTransform.Scale.ScaleX = 1;
            rectangleDialogElement.ElementTransform.Scale.ScaleY = 1;
            rectangleDialogElement.ElementTransform.Scale.CenterX = 0;
            rectangleDialogElement.ElementTransform.Scale.CenterY = 0;

            rectangleDialogElement.ElementTransform.Translate.X = 0;
            rectangleDialogElement.ElementTransform.Translate.Y = 0;

            rectangleDialogElement.ElementTransform.Margin = new Windows.UI.Xaml.Thickness(0, 0, 0, 0);

            rectangleDialogElement.ElementTransform.Width = 200;
            rectangleDialogElement.ElementTransform.Height = 200;

            rectangleDialogElement.TextMarginLeft = 0;
            rectangleDialogElement.TextMarginTop = 0;
            rectangleDialogElement.TextMaxHeight = 200;
            rectangleDialogElement.TextWidth = 200;

            rectangleDialogElement.TextAlignment = SerializeCast.StringToTextAlignment("CenterCenter");

            rectangleDialogElement.ShapeStyle = SerializeCast.StringToTextBoxStyle("NoBorderBKG");
            rectangleDialogElement.BorderColor = Color.FromArgb(255, 0, 0, 0);
            rectangleDialogElement.BorderWidth = 0;

            rectangleDialogElement.ShapeFillColor = Color.FromArgb(255, 24, 122, 169);
            rectangleDialogElement.ShapeWidth = 200;
            rectangleDialogElement.ShapeHeight = 200;

            rectangleDialogElement.ControlPanelTop = 0;
            rectangleDialogElement.ControlPanelLeft = 0;

            rectangleDialogElement.FigureStartPoint = new Point(0, 40);
            rectangleDialogElement.RoundedLeftTopPoint1 = new Point(0, 40);
            rectangleDialogElement.RoundedLeftTopPoint2 = new Point(0, 0);
            rectangleDialogElement.RoundedLeftTopPoint3 = new Point(40, 0);
            rectangleDialogElement.LineTopStartPoint = new Point(40, 0);
            rectangleDialogElement.LineTopEndPoint = new Point(180, 0);
            rectangleDialogElement.RoundedRightTopPoint1 = new Point(180, 0);
            rectangleDialogElement.RoundedRightTopPoint2 = new Point(220, 0);
            rectangleDialogElement.RoundedRightTopPoint3 = new Point(220, 40);
            rectangleDialogElement.LineRightStartPoint = new Point(220, 40);
            rectangleDialogElement.LineRightEndPoint = new Point(220, 100);
            rectangleDialogElement.RoundedRightBottomPoint1 = new Point(220, 100);
            rectangleDialogElement.RoundedRightBottomPoint2 = new Point(220, 140);
            rectangleDialogElement.RoundedRightBottomPoint3 = new Point(180, 140);
            rectangleDialogElement.LineDialog1StartPoint = new Point(180, 140);
            rectangleDialogElement.LineDialog1EndPoint = new Point(rectangleDialogElement.ShapeWidth - 50, rectangleDialogElement.ShapeHeight+50);
            rectangleDialogElement.LineDialog2StartPoint = new Point(175, 175);
            rectangleDialogElement.LineDialog2EndPoint = new Point(145, 140);
            rectangleDialogElement.LineBottomStartPoint = new Point(145, 140);
            rectangleDialogElement.lineBottomEndPoint = new Point(40, 140);
            rectangleDialogElement.RoundedLeftBottomPoint1 = new Point(40, 140);
            rectangleDialogElement.RoundedLeftBottomPoint2 = new Point(0, 140);
            rectangleDialogElement.RoundedLeftBottomPoint3 = new Point(0, 100);
            rectangleDialogElement.LineLeftStartPoint = new Point(0, 100);
            rectangleDialogElement.LineLeftEndPoint = new Point(0, 40);

            rectangleDialogElement.Text = "";
            return rectangleDialogElement;
        }

        public override XElement SaveToXElement()
        {
            XElement element = new XElement(typeof(BooRectangleDialogElement).Name);
            element.SetAttributeValue("UniqueID", UniqueID.ToString());
            element.Add(ElementTransform.Save());
            XElement styleElement = SaveShapeStyle();
   
            XElement xFigureStartPoint = new XElement("FigureStartPoint");
            xFigureStartPoint.SetAttributeValue("X", this.FigureStartPoint.X);
            xFigureStartPoint.SetAttributeValue("Y", this.FigureStartPoint.Y);
            XElement xRoundedLeftTopPoint1 = new XElement("RoundedLeftTopPoint1");
            xRoundedLeftTopPoint1.SetAttributeValue("X", this.RoundedLeftTopPoint1.X);
            xRoundedLeftTopPoint1.SetAttributeValue("Y", this.RoundedLeftTopPoint1.Y);
            XElement xRoundedLeftTopPoint2 = new XElement("RoundedLeftTopPoint2");
            xRoundedLeftTopPoint2.SetAttributeValue("X", this.RoundedLeftTopPoint2.X);
            xRoundedLeftTopPoint2.SetAttributeValue("Y", this.RoundedLeftTopPoint2.Y);
            XElement xRoundedLeftTopPoint3 = new XElement("RoundedLeftTopPoint3");
            xRoundedLeftTopPoint3.SetAttributeValue("X", this.RoundedLeftTopPoint3.X);
            xRoundedLeftTopPoint3.SetAttributeValue("Y", this.RoundedLeftTopPoint3.Y);

            XElement xLineTopStartPoint = new XElement("LineTopStartPoint");
            xLineTopStartPoint.SetAttributeValue("X", this.LineTopStartPoint.X);
            xLineTopStartPoint.SetAttributeValue("Y", this.LineTopStartPoint.Y);
            XElement xLineTopEndPoint = new XElement("LineTopEndPoint");
            xLineTopEndPoint.SetAttributeValue("X", this.LineTopEndPoint.X);
            xLineTopEndPoint.SetAttributeValue("Y", this.LineTopEndPoint.Y);

            XElement xRoundedRightTopPoint1 = new XElement("RoundedRightTopPoint1");
            xRoundedRightTopPoint1.SetAttributeValue("X", this.RoundedRightTopPoint1.X);
            xRoundedRightTopPoint1.SetAttributeValue("Y", this.RoundedRightTopPoint1.Y);
            XElement xRoundedRightTopPoint2 = new XElement("RoundedRightTopPoint2");
            xRoundedRightTopPoint2.SetAttributeValue("X", this.RoundedRightTopPoint2.X);
            xRoundedRightTopPoint2.SetAttributeValue("Y", this.RoundedRightTopPoint2.Y);
            XElement xRoundedRightTopPoint3 = new XElement("RoundedRightTopPoint3");
            xRoundedRightTopPoint3.SetAttributeValue("X", this.RoundedRightTopPoint3.X);
            xRoundedRightTopPoint3.SetAttributeValue("Y", this.RoundedRightTopPoint3.Y);

            XElement xLineRightStartPoint = new XElement("LineRightStartPoint");
            xLineRightStartPoint.SetAttributeValue("X", this.LineRightStartPoint.X);
            xLineRightStartPoint.SetAttributeValue("Y", this.LineRightStartPoint.Y);
            XElement xLineRightEndPoint = new XElement("LineRightEndPoint");
            xLineRightEndPoint.SetAttributeValue("X", this.LineRightEndPoint.X);
            xLineRightEndPoint.SetAttributeValue("Y", this.LineRightEndPoint.Y);

            XElement xRoundedRightBottomPoint1 = new XElement("RoundedRightBottomPoint1");
            xRoundedRightBottomPoint1.SetAttributeValue("X", this.RoundedRightBottomPoint1.X);
            xRoundedRightBottomPoint1.SetAttributeValue("Y", this.RoundedRightBottomPoint1.Y);
            XElement xRoundedRightBottomPoint2 = new XElement("RoundedRightBottomPoint2");
            xRoundedRightBottomPoint2.SetAttributeValue("X", this.RoundedRightBottomPoint2.X);
            xRoundedRightBottomPoint2.SetAttributeValue("Y", this.RoundedRightBottomPoint2.Y);
            XElement xRoundedRightBottomPoint3 = new XElement("RoundedRightBottomPoint3");
            xRoundedRightBottomPoint3.SetAttributeValue("X", this.RoundedRightBottomPoint3.X);
            xRoundedRightBottomPoint3.SetAttributeValue("Y", this.RoundedRightBottomPoint3.Y);

            XElement xLineDialog1StartPoint = new XElement("LineDialog1StartPoint");
            xLineDialog1StartPoint.SetAttributeValue("X", this.LineDialog1StartPoint.X);
            xLineDialog1StartPoint.SetAttributeValue("Y", this.LineDialog1StartPoint.Y);
            XElement xLineDialog1EndPoint = new XElement("LineDialog1EndPoint");
            xLineDialog1EndPoint.SetAttributeValue("X", this.LineDialog1EndPoint.X);
            xLineDialog1EndPoint.SetAttributeValue("Y", this.LineDialog1EndPoint.Y);

            XElement xLineDialog2StartPoint = new XElement("LineDialog2StartPoint");
            xLineDialog2StartPoint.SetAttributeValue("X", this.LineDialog2StartPoint.X);
            xLineDialog2StartPoint.SetAttributeValue("Y", this.LineDialog2StartPoint.Y);
            XElement xLineDialog2EndPoint = new XElement("LineDialog2EndPoint");
            xLineDialog2EndPoint.SetAttributeValue("X", this.LineDialog2EndPoint.X);
            xLineDialog2EndPoint.SetAttributeValue("Y", this.LineDialog2EndPoint.Y);

            XElement xLineBottomStartPoint = new XElement("LineBottomStartPoint");
            xLineBottomStartPoint.SetAttributeValue("X", this.LineBottomStartPoint.X);
            xLineBottomStartPoint.SetAttributeValue("Y", this.LineBottomStartPoint.Y);
            XElement xLineBottomEndPoint = new XElement("LineBottomEndPoint");
            xLineBottomEndPoint.SetAttributeValue("X", this.LineBottomEndPoint.X);
            xLineBottomEndPoint.SetAttributeValue("Y", this.LineBottomEndPoint.Y);

            XElement xRoundedLeftBottomPoint1 = new XElement("RoundedLeftBottomPoint1");
            xRoundedLeftBottomPoint1.SetAttributeValue("X", this.RoundedRightBottomPoint1.X);
            xRoundedLeftBottomPoint1.SetAttributeValue("Y", this.RoundedRightBottomPoint1.Y);
            XElement xRoundedLeftBottomPoint2 = new XElement("RoundedLeftBottomPoint2");
            xRoundedLeftBottomPoint2.SetAttributeValue("X", this.RoundedRightBottomPoint2.X);
            xRoundedLeftBottomPoint2.SetAttributeValue("Y", this.RoundedRightBottomPoint2.Y);
            XElement xRoundedLeftBottomPoint3 = new XElement("RoundedLeftBottomPoint3");
            xRoundedLeftBottomPoint3.SetAttributeValue("X", this.RoundedRightBottomPoint3.X);
            xRoundedLeftBottomPoint3.SetAttributeValue("Y", this.RoundedRightBottomPoint3.Y);

            XElement xLineLeftStartPoint = new XElement("LineLeftStartPoint");
            xLineLeftStartPoint.SetAttributeValue("X", this.LineLeftStartPoint.X);
            xLineLeftStartPoint.SetAttributeValue("Y", this.LineLeftStartPoint.Y);
            XElement xLineLeftEndPoint = new XElement("LineLeftEndPoint");
            xLineLeftEndPoint.SetAttributeValue("X", this.LineLeftEndPoint.X);
            xLineLeftEndPoint.SetAttributeValue("Y", this.LineLeftEndPoint.Y);

            element.Add(styleElement);
            element.Add(xFigureStartPoint);
            element.Add(xRoundedLeftTopPoint1);
            element.Add(xRoundedLeftTopPoint2);
            element.Add(xRoundedLeftTopPoint3);
            element.Add(xLineTopStartPoint);
            element.Add(xLineTopEndPoint);
            element.Add(xRoundedRightTopPoint1);
            element.Add(xRoundedRightTopPoint2);
            element.Add(xRoundedRightTopPoint3);
            element.Add(xLineRightStartPoint);
            element.Add(xLineRightEndPoint);
            element.Add(xRoundedRightBottomPoint1);
            element.Add(xRoundedRightBottomPoint2);
            element.Add(xRoundedRightBottomPoint3);
            element.Add(xLineDialog1StartPoint);
            element.Add(xLineDialog1EndPoint);
            element.Add(xLineDialog2StartPoint);
            element.Add(xLineDialog2EndPoint);
            element.Add(xLineBottomStartPoint);
            element.Add(xLineBottomEndPoint);
            element.Add(xRoundedLeftBottomPoint1);
            element.Add(xRoundedLeftBottomPoint2);
            element.Add(xRoundedLeftBottomPoint3);
            element.Add(xLineLeftStartPoint);
            element.Add(xLineLeftEndPoint);

            element.Add(SaveData());

            return element;
        }

        public override void LoadFromXElement(XElement element)
        {
            XElement tranformElement = element.Element("Transform");
            XElement dataElement = element.Element("Data");
            XElement styleElement = element.Element("Style");

            ElementTransform.Load(tranformElement);
            LoadShapeStyle(styleElement);
            LoadData(dataElement);

            XElement xFigureStartPoint = element.Element("FigureStartPoint");
            double xFigureStartPointx = Double.Parse(xFigureStartPoint.Attribute("X").Value);
            double xFigureStartPointy = Double.Parse(xFigureStartPoint.Attribute("Y").Value);
            this.FigureStartPoint = new Point(xFigureStartPointx, xFigureStartPointy);

            XElement xRoundedLeftTopPoint1 = element.Element("RoundedLeftTopPoint1");
            double xRoundedLeftTopPoint1x = Double.Parse(xRoundedLeftTopPoint1.Attribute("X").Value);
            double xRoundedLeftTopPoint1y = Double.Parse(xRoundedLeftTopPoint1.Attribute("Y").Value);
            this.RoundedLeftTopPoint1 = new Point(xRoundedLeftTopPoint1x, xRoundedLeftTopPoint1y);

            XElement xRoundedLeftTopPoint2 = element.Element("RoundedLeftTopPoint2");
            double xRoundedLeftTopPoint2x = Double.Parse(xRoundedLeftTopPoint2.Attribute("X").Value);
            double xRoundedLeftTopPoint2y = Double.Parse(xRoundedLeftTopPoint2.Attribute("Y").Value);
            this.RoundedLeftTopPoint2 = new Point(xRoundedLeftTopPoint2x, xRoundedLeftTopPoint2y);

            XElement xRoundedLeftTopPoint3 = element.Element("RoundedLeftTopPoint3");
            double xRoundedLeftTopPoint3x = Double.Parse(xRoundedLeftTopPoint3.Attribute("X").Value);
            double xRoundedLeftTopPoint3y = Double.Parse(xRoundedLeftTopPoint3.Attribute("Y").Value);
            this.RoundedLeftTopPoint3 = new Point(xRoundedLeftTopPoint3x, xRoundedLeftTopPoint3y);

            XElement xLineTopStartPoint = element.Element("LineTopStartPoint");
            double xLineTopStartPointx = Double.Parse(xLineTopStartPoint.Attribute("X").Value);
            double xLineTopStartPointy = Double.Parse(xLineTopStartPoint.Attribute("Y").Value);
            this.LineTopStartPoint = new Point(xLineTopStartPointx, xLineTopStartPointy);

            XElement xLineTopEndPoint = element.Element("LineTopEndPoint");
            double xLineTopEndPointx = Double.Parse(xLineTopEndPoint.Attribute("X").Value);
            double xLineTopEndPointy = Double.Parse(xLineTopEndPoint.Attribute("Y").Value);
            this.LineTopEndPoint = new Point(xLineTopEndPointx, xLineTopEndPointy);

            XElement xRoundedRightTopPoint1 = element.Element("RoundedRightTopPoint1");
            double xRoundedRightTopPoint1x = Double.Parse(xRoundedRightTopPoint1.Attribute("X").Value);
            double xRoundedRightTopPoint1y = Double.Parse(xRoundedRightTopPoint1.Attribute("Y").Value);
            this.RoundedRightTopPoint1 = new Point(xRoundedRightTopPoint1x, xRoundedRightTopPoint1y);

            XElement xRoundedRightTopPoint2 = element.Element("RoundedRightTopPoint2");
            double xRoundedRightTopPoint2x = Double.Parse(xRoundedRightTopPoint2.Attribute("X").Value);
            double xRoundedRightTopPoint2y = Double.Parse(xRoundedRightTopPoint2.Attribute("Y").Value);
            this.RoundedRightTopPoint2 = new Point(xRoundedRightTopPoint2x, xRoundedRightTopPoint2y);

            XElement xRoundedRightTopPoint3 = element.Element("RoundedRightTopPoint3");
            double xRoundedRightTopPoint3x = Double.Parse(xRoundedRightTopPoint3.Attribute("X").Value);
            double xRoundedRightTopPoint3y = Double.Parse(xRoundedRightTopPoint3.Attribute("Y").Value);
            this.RoundedRightTopPoint3 = new Point(xRoundedRightTopPoint3x, xRoundedRightTopPoint3y);

            XElement xLineRightStartPoint = element.Element("LineRightStartPoint");
            double xLineRightStartPointx = Double.Parse(xLineRightStartPoint.Attribute("X").Value);
            double xLineRightStartPointy = Double.Parse(xLineRightStartPoint.Attribute("Y").Value);
            this.LineRightStartPoint = new Point(xLineRightStartPointx, xLineRightStartPointy);

            XElement xLineRightEndPoint = element.Element("LineRightEndPoint");
            double xLineRightEndPointx = Double.Parse(xLineRightEndPoint.Attribute("X").Value);
            double xLineRightEndPointy = Double.Parse(xLineRightEndPoint.Attribute("Y").Value);
            this.LineRightEndPoint = new Point(xLineRightEndPointx, xLineRightEndPointy);

            XElement xRoundedRightBottomPoint1 = element.Element("RoundedRightBottomPoint1");
            double xRoundedRightBottomPoint1x = Double.Parse(xRoundedRightBottomPoint1.Attribute("X").Value);
            double xRoundedRightBottomPoint1y = Double.Parse(xRoundedRightBottomPoint1.Attribute("Y").Value);
            this.RoundedRightBottomPoint1 = new Point(xRoundedRightBottomPoint1x, xRoundedRightBottomPoint1y);

            XElement xRoundedRightBottomPoint2 = element.Element("RoundedRightBottomPoint2");
            double xRoundedRightBottomPoint2x = Double.Parse(xRoundedRightBottomPoint2.Attribute("X").Value);
            double xRoundedRightBottomPoint2y = Double.Parse(xRoundedRightBottomPoint2.Attribute("Y").Value);
            this.roundedRightBottomPoint2 = new Point(xRoundedRightBottomPoint2x, xRoundedRightBottomPoint2y);

            XElement xRoundedRightBottomPoint3 = element.Element("RoundedRightBottomPoint3");
            double xRoundedRightBottomPoint3x = Double.Parse(xRoundedRightBottomPoint3.Attribute("X").Value);
            double xRoundedRightBottomPoint3y = Double.Parse(xRoundedRightBottomPoint3.Attribute("Y").Value);
            this.RoundedRightBottomPoint3 = new Point(xRoundedRightBottomPoint3x, xRoundedRightBottomPoint3y);

            XElement xLineDialog1StartPoint = element.Element("LineDialog1StartPoint");
            double xLineDialog1StartPointx = Double.Parse(xLineDialog1StartPoint.Attribute("X").Value);
            double xLineDialog1StartPointy = Double.Parse(xLineDialog1StartPoint.Attribute("Y").Value);
            this.LineDialog1StartPoint = new Point(xLineDialog1StartPointx, xLineDialog1StartPointy);

            XElement xLineDialog1EndPoint = element.Element("LineDialog1EndPoint");
            double xLineDialog1EndPointx = Double.Parse(xLineDialog1EndPoint.Attribute("X").Value);
            double xLineDialog1EndPointy = Double.Parse(xLineDialog1EndPoint.Attribute("Y").Value);
            this.LineDialog1EndPoint = new Point(xLineDialog1EndPointx, xLineDialog1EndPointy);

            XElement xLineDialog2StartPoint = element.Element("LineDialog2StartPoint");
            double xLineDialog2StartPointx = Double.Parse(xLineDialog2StartPoint.Attribute("X").Value);
            double xLineDialog2StartPointy = Double.Parse(xLineDialog2StartPoint.Attribute("Y").Value);
            this.LineDialog2StartPoint = new Point(xLineDialog2StartPointx, xLineDialog2StartPointy);

            XElement xLineDialog2EndPoint = element.Element("LineDialog2EndPoint");
            double xLineDialog2EndPointx = Double.Parse(xLineDialog2EndPoint.Attribute("X").Value);
            double xLineDialog2EndPointy = Double.Parse(xLineDialog2EndPoint.Attribute("Y").Value);
            this.LineDialog2EndPoint = new Point(xLineDialog2EndPointx, xLineDialog2EndPointy);

            XElement xLineBottomStartPoint = element.Element("LineBottomStartPoint");
            double xLineBottomStartPointx = Double.Parse(xLineBottomStartPoint.Attribute("X").Value);
            double xLineBottomStartPointy = Double.Parse(xLineBottomStartPoint.Attribute("Y").Value);
            this.LineBottomStartPoint = new Point(xLineBottomStartPointx, xLineBottomStartPointy);

            XElement xLineBottomEndPoint = element.Element("LineBottomEndPoint");
            double xLineBottomEndPointx = Double.Parse(xLineBottomEndPoint.Attribute("X").Value);
            double xLineBottomEndPointy = Double.Parse(xLineBottomEndPoint.Attribute("Y").Value);
            this.LineBottomEndPoint = new Point(xLineBottomEndPointx, xLineBottomEndPointy);

            XElement xRoundedLeftBottomPoint1 = element.Element("RoundedLeftBottomPoint1");
            double xRoundedLeftBottomPoint1x = Double.Parse(xRoundedLeftBottomPoint1.Attribute("X").Value);
            double xRoundedLeftBottomPoint1y = Double.Parse(xRoundedLeftBottomPoint1.Attribute("Y").Value);
            this.RoundedLeftBottomPoint1 = new Point(xRoundedLeftBottomPoint1x, xRoundedLeftBottomPoint1y);

            XElement xRoundedLeftBottomPoint2 = element.Element("RoundedLeftBottomPoint2");
            double xRoundedLeftBottomPoint2x = Double.Parse(xRoundedLeftBottomPoint2.Attribute("X").Value);
            double xRoundedLeftBottomPoint2y = Double.Parse(xRoundedLeftBottomPoint2.Attribute("Y").Value);
            this.RoundedLeftBottomPoint2 = new Point(xRoundedLeftBottomPoint2x, xRoundedLeftBottomPoint2y);

            XElement xRoundedLeftBottomPoint3 = element.Element("RoundedLeftBottomPoint3");
            double xRoundedLeftBottomPoint3x = Double.Parse(xRoundedLeftBottomPoint3.Attribute("X").Value);
            double xRoundedLeftBottomPoint3y = Double.Parse(xRoundedLeftBottomPoint3.Attribute("Y").Value);
            this.RoundedLeftBottomPoint3 = new Point(xRoundedLeftBottomPoint3x, xRoundedLeftBottomPoint3y);

            XElement xLineLeftStartPoint = element.Element("LineLeftStartPoint");
            double xLineLeftStartPointx = Double.Parse(xLineLeftStartPoint.Attribute("X").Value);
            double xLineLeftStartPointy = Double.Parse(xLineLeftStartPoint.Attribute("Y").Value);
            this.LineLeftStartPoint = new Point(xLineLeftStartPointx, xLineLeftStartPointy);

            XElement xLineLeftEndPoint = element.Element("LineLeftEndPoint");
            double xLineLeftEndPointx = Double.Parse(xLineLeftEndPoint.Attribute("X").Value);
            double xLineLeftEndPointy = Double.Parse(xLineLeftEndPoint.Attribute("Y").Value);
            this.LineLeftEndPoint = new Point(xLineLeftEndPointx, xLineLeftEndPointy);
        }

        public override BooElement Clone()
        {
            BooRectangleDialogElement element = new BooRectangleDialogElement();
            element.ElementTransform = this.ElementTransform.Clone();

            element.TextMarginLeft = this.TextMarginLeft;
            element.TextMarginTop = this.TextMarginTop;
            element.TextMaxHeight = this.TextMaxHeight;
            element.TextWidth = this.TextWidth;

            element.TextAlignment = this.TextAlignment;

            element.ShapeStyle = this.ShapeStyle;
            element.BorderColor = Color.FromArgb(this.BorderColor.A, this.BorderColor.R, this.BorderColor.G, this.BorderColor.B);
            element.BorderWidth = this.BorderWidth;

            element.ShapeFillColor = Color.FromArgb(this.ShapeFillColor.A, this.ShapeFillColor.R, this.ShapeFillColor.G, this.ShapeFillColor.B);
            element.ShapeWidth = this.ShapeWidth;
            element.ShapeHeight = this.ShapeHeight;

            element.ControlPanelTop = this.ControlPanelTop;
            element.ControlPanelLeft = this.ControlPanelLeft;
            element.Text = this.Text;

            element.FigureStartPoint = new Point(this.FigureStartPoint.X, this.FigureStartPoint.Y);
            element.RoundedLeftTopPoint1 = new Point(this.RoundedLeftTopPoint1.X, this.RoundedLeftTopPoint1.Y);
            element.RoundedLeftTopPoint2 = new Point(this.RoundedLeftTopPoint2.X, this.RoundedLeftTopPoint2.Y);
            element.RoundedLeftTopPoint3 = new Point(this.RoundedLeftTopPoint3.X, this.RoundedLeftTopPoint3.Y);
            element.LineTopStartPoint = new Point(this.LineTopStartPoint.X, this.LineTopStartPoint.Y);
            element.LineTopEndPoint = new Point(this.LineTopEndPoint.X, this.LineTopEndPoint.Y);
            element.RoundedRightTopPoint1 = new Point(this.RoundedRightTopPoint1.X, this.RoundedRightTopPoint1.Y);
            element.RoundedRightTopPoint2 = new Point(this.RoundedRightTopPoint2.X, this.RoundedRightTopPoint2.Y);
            element.RoundedRightTopPoint3 = new Point(this.RoundedRightTopPoint3.X, this.RoundedRightTopPoint3.Y);
            element.LineRightStartPoint = new Point(this.LineRightStartPoint.X, this.LineRightStartPoint.Y);
            element.LineRightEndPoint = new Point(this.LineRightEndPoint.X, this.LineRightEndPoint.Y);
            element.RoundedRightBottomPoint1 = new Point(this.RoundedRightBottomPoint1.X, this.RoundedRightBottomPoint1.Y);
            element.RoundedRightBottomPoint2 = new Point(this.RoundedRightBottomPoint2.X, this.RoundedRightBottomPoint2.Y);
            element.RoundedRightBottomPoint3 = new Point(this.RoundedRightBottomPoint3.X, this.RoundedRightBottomPoint3.Y);
            element.LineDialog1StartPoint = new Point(this.RoundedRightBottomPoint3.X, this.RoundedRightBottomPoint3.Y);
            element.LineDialog1EndPoint = new Point(this.LineDialog1EndPoint.X, this.LineDialog1EndPoint.Y);
            element.LineDialog2StartPoint = new Point(this.LineDialog2StartPoint.X, this.LineDialog2StartPoint.Y);
            element.LineDialog2EndPoint = new Point(this.LineDialog2EndPoint.X, this.LineDialog2EndPoint.Y);
            element.LineBottomStartPoint = new Point(this.LineBottomStartPoint.X, this.LineBottomStartPoint.Y);
            element.LineBottomEndPoint = new Point(this.LineBottomEndPoint.X, this.LineBottomEndPoint.Y);
            element.RoundedLeftBottomPoint1 = new Point(this.RoundedLeftBottomPoint1.X, this.RoundedLeftBottomPoint1.Y);
            element.RoundedLeftBottomPoint2 = new Point(this.RoundedLeftBottomPoint2.X, this.RoundedLeftBottomPoint2.Y);
            element.RoundedLeftBottomPoint3 = new Point(this.RoundedLeftBottomPoint3.X, this.RoundedLeftBottomPoint3.Y);
            element.LineLeftStartPoint = new Point(this.LineLeftStartPoint.X, this.LineLeftStartPoint.Y);
            element.LineLeftEndPoint = new Point(this.LineLeftEndPoint.X, this.LineLeftEndPoint.Y);


            return element;
        }

        public override void Load(BooTextShapesBaseElement shapesElement)
        {
            BooRectangleDialogElement ele = shapesElement as BooRectangleDialogElement;
            this.ElementTransform = ele.ElementTransform;

            this.TextMarginLeft = ele.TextMarginLeft;
            this.TextMarginTop = ele.TextMarginTop;
            this.TextMaxHeight = ele.TextMaxHeight;
            this.TextWidth = ele.TextWidth;

            this.TextAlignment = ele.TextAlignment;

            this.ShapeStyle = ele.ShapeStyle;
            this.BorderColor = Color.FromArgb(ele.BorderColor.A, ele.BorderColor.R, ele.BorderColor.G, ele.BorderColor.B);
            this.BorderWidth = ele.BorderWidth;

            this.ShapeFillColor = Color.FromArgb(ele.ShapeFillColor.A, ele.ShapeFillColor.R, ele.ShapeFillColor.G, ele.ShapeFillColor.B);
            this.ShapeWidth = ele.ShapeWidth;
            this.ShapeHeight = ele.ShapeHeight;

            this.ControlPanelTop = ele.ControlPanelTop;
            this.ControlPanelLeft = ele.ControlPanelLeft;
            this.Text = ele.Text;

            this.FigureStartPoint = new Point(ele.FigureStartPoint.X, ele.FigureStartPoint.Y);
            this.RoundedLeftTopPoint1 = new Point(ele.RoundedLeftTopPoint1.X, ele.RoundedLeftTopPoint1.Y);
            this.RoundedLeftTopPoint2 = new Point(ele.RoundedLeftTopPoint2.X, ele.RoundedLeftTopPoint2.Y);
            this.RoundedLeftTopPoint3 = new Point(ele.RoundedLeftTopPoint3.X, ele.RoundedLeftTopPoint3.Y);
            this.LineTopStartPoint = new Point(ele.LineTopStartPoint.X, ele.LineTopStartPoint.Y);
            this.LineTopEndPoint = new Point(ele.LineTopEndPoint.X, ele.LineTopEndPoint.Y);
            this.RoundedRightTopPoint1 = new Point(ele.RoundedRightTopPoint1.X, ele.RoundedRightTopPoint1.Y);
            this.RoundedRightTopPoint2 = new Point(ele.RoundedRightTopPoint2.X, ele.RoundedRightTopPoint2.Y);
            this.RoundedRightTopPoint3 = new Point(ele.RoundedRightTopPoint3.X, ele.RoundedRightTopPoint3.Y);
            this.LineRightStartPoint = new Point(ele.LineRightStartPoint.X, ele.LineRightStartPoint.Y);
            this.LineRightEndPoint = new Point(ele.LineRightEndPoint.X, ele.LineRightEndPoint.Y);
            this.RoundedRightBottomPoint1 = new Point(ele.RoundedRightBottomPoint1.X, ele.RoundedRightBottomPoint1.Y);
            this.RoundedRightBottomPoint2 = new Point(ele.RoundedRightBottomPoint2.X, ele.RoundedRightBottomPoint2.Y);
            this.RoundedRightBottomPoint3 = new Point(ele.RoundedRightBottomPoint3.X, ele.RoundedRightBottomPoint3.Y);
            this.LineDialog1StartPoint = new Point(ele.RoundedRightBottomPoint3.X, ele.RoundedRightBottomPoint3.Y);
            this.LineDialog1EndPoint = new Point(ele.LineDialog1EndPoint.X, ele.LineDialog1EndPoint.Y);
            this.LineDialog2StartPoint = new Point(ele.LineDialog2StartPoint.X, ele.LineDialog2StartPoint.Y);
            this.LineDialog2EndPoint = new Point(ele.LineDialog2EndPoint.X, ele.LineDialog2EndPoint.Y);
            this.LineBottomStartPoint = new Point(ele.LineBottomStartPoint.X, ele.LineBottomStartPoint.Y);
            this.LineBottomEndPoint = new Point(ele.LineBottomEndPoint.X, ele.LineBottomEndPoint.Y);
            this.RoundedLeftBottomPoint1 = new Point(ele.RoundedLeftBottomPoint1.X, ele.RoundedLeftBottomPoint1.Y);
            this.RoundedLeftBottomPoint2 = new Point(ele.RoundedLeftBottomPoint2.X, ele.RoundedLeftBottomPoint2.Y);
            this.RoundedLeftBottomPoint3 = new Point(ele.RoundedLeftBottomPoint3.X, ele.RoundedLeftBottomPoint3.Y);
            this.LineLeftStartPoint = new Point(ele.LineLeftStartPoint.X, ele.LineLeftStartPoint.Y);
            this.LineLeftEndPoint = new Point(ele.LineLeftEndPoint.X, ele.LineLeftEndPoint.Y);
        }
    }
}
